package com.fengycx.remote.impl;

import cn.hutool.core.bean.BeanUtil;
import com.fengycx.feign.DriverHbaseGeoApi;
import com.fengycx.mapper.DriverGeoMapper;
import com.fengycx.pojo.dto.DriverPointDto;
import com.fengycx.pojo.vo.PointVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;


@RestController
public class DriverHbaseGeoImpl implements DriverHbaseGeoApi {

    @Autowired
    private DriverGeoMapper driverGeoMapper;

    /**
     * 根据订单号查找司机坐标集合返回前端进行画线
     * @param orderNo
     * @return
     */
    @Override
    public List<PointVo> getDriverGeoList(String orderNo) {
        List<DriverPointDto> driverPoints = driverGeoMapper.selectByOrderNo(orderNo);
        return driverPoints.stream().map(d -> {
            PointVo pointVo = new PointVo();
            BeanUtil.copyProperties(d, pointVo);
            return pointVo;
        }).toList();
    }
}
